[SRLT-135] 에러 수정#108
Hidden character warning
Conversation
This reverts commit 880f499.
…into SRLT-135-에러-수정
WalkthroughAPI 토큰 갱신 실패와 401 처리에서 localStorage 직접 제거를 중앙화된 Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client(UI)
participant Header as Header/Sidebar
participant Auth as useAuthStore
participant API as API Layer
participant Modal as LoginModal
UI->>Header: 클릭("작성하기"/"채점하기"/"create")
Header->>Auth: isAuthenticated? (read)
alt authenticated
Header->>UI: open Upload/Business (navigate)
else not authenticated
Header->>Modal: open LoginModal
Modal->>Auth: 로그인 시도 -> API (credentials)
API->>Auth: 토큰 수신 -> set auth state
Auth->>Header: auth state updated
Header->>UI: now navigate (if applicable)
end
Note over API,Auth: 토큰 갱신 실패 또는 401 발생 시
API->>Auth: useAuthStore.getState().logout()
Auth->>UI: clear auth/user state (centralized)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/app/expert/detail/components/ExpertDetailSidebar.tsx`:
- Around line 28-30: The current hasAccessToken/isMember logic in
ExpertDetailSidebar uses localStorage.getItem (hasAccessToken) which is not
reactive; replace that with the auth store's reactive flag: import and call
useAuthStore() and derive hasAccessToken (or better, isAuthenticated) from
useAuthStore().isAuthenticated, then compute isMember from that and user (update
the symbols hasAccessToken and isMember inside ExpertDetailSidebar accordingly);
also apply the same change to the other block around the second occurrence
(lines 69-73) so both places use the reactive useAuthStore().isAuthenticated
instead of localStorage.
🧹 Nitpick comments (1)
src/app/_components/common/Header.tsx (1)
81-87:clearUser()중복 호출
handleLogout에서clearUser()를 직접 호출하고 있지만,logout()이isAuthenticated를false로 변경하면 Line 25-31의useEffect에서도clearUser()가 다시 호출됩니다. 동작에 문제는 없으나 불필요한 중복입니다.♻️ 제안
const handleLogout = () => { logout(); - clearUser(); router.push('/'); setIsProfileOpen(false); };
#️⃣ 관련 이슈
✍️ 작업 내용 요약
💡 작업 내용
기능
🖥️ 구현 화면
기타 사항
Summary by CodeRabbit
새로운 기능
버그 수정 / 동작 변경